<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8">
	</head>
<body>

<?php
$cookie_file = dirname(__FILE__)."/cookie.txt";
$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9';
$referer="http://www.chsi.com.cn/cet/";
$zkzh="320111122108804";
$xm="张天朔";
	
$ch = curl_init();
//设置URL
//curl_setopt($ch, CURLOPT_URL,"http://www.chsi.com.cn/cet/query?zkzh=320111122108804&xm=%E5%BC%A0%E5%A4%A9%E6%9C%94");
curl_setopt($ch, CURLOPT_URL,"http://www.chsi.com.cn/cet/query?zkzh=320111122108804&xm=%E5%BC%A0%E5%A4%A9%E6%9C%94");
//设置user_agent
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);	
//设置referer
curl_setopt($ch, CURLOPT_REFERER, $referer);
//连接关闭以后，存放cookie信息的文件名称
//curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
//curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
//成功时返回结果
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//设置超时30秒
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
// 显示返回的Header区域内容
curl_setopt($ch, CURLOPT_HEADER, 0); 
// 显示重定向
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//设置POST及POST数组
//curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//执行并获取HTML文档内容
$output = curl_exec($ch);
//获取执行信息
$info = curl_getinfo($ch);
$error=curl_error($ch);
//释放curl句柄
curl_close($ch);

if($error===''){$error="None";}

//echo $output;
//echo '<br />获取'. $info['url'] . '耗时'. $info['total_time'] . "秒<br />";
//echo "<br />错误：$error<br />";

preg_match_all('/\<td\>([^<>]+)\<\/td\>/', $output, $user_info);
preg_match_all('/\<\/span\>([^<>]+)\<span/', $output, $user_grade);	
preg_match('/\<\/span\>([^<>]+)\<\/strong/', $output, $user_grade2);	
	
preg_match('/\<span style\=\"color: #F00;\"\>([^<>]+)\<\/span\>/', $output, $all_score);

echo "总分：".$all_score['0']."<br />";

echo "姓名：".$user_info['0']['0']."<br />";
echo "学校：".$user_info['0']['1']."<br />";
echo "考试：".$user_info['0']['2']."<br />";
echo "准考证号：".$user_info['0']['3']."<br />";
echo "时间：".$user_info['0']['4']."<br />";
	
	

echo '<br />
<strong><span style="color: #F00;">总分：'.$all_score['0'].'</span><br />
<span >听力：</span>'.$user_grade['0']['1'].'<br />
<span >阅读：</span>'.$user_grade['0']['2'].'<br />
<span >综合：</span>'.$user_grade['0']['3'].'<br />
<span >写作与翻译：</span>'.$user_grade2['0'].'</strong><br />


';


?>

</>
</html>